package com.crud.service.impl;

import com.crud.entity.User;
import com.crud.mapper.UserMapper;
import com.crud.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * @author hyh
 * @date 2023/06/28 18:45:02
 */
@Service
@Transactional
public class UserServiceImpl implements UserService {
    @Autowired
    private UserMapper userMapper;
    @Override
    public User save(User user) {
        userMapper.insert(user);
        return user;
    }

    @Override
    public int delete(Integer id) {
        int i = userMapper.deleteByPrimaryKey(id);
        return i;
    }

    @Override
    public List<User> findAll() {
        return userMapper.selectByExample(null);
    }

    @Override
    public int update(User user) {
        return 0;
    }
}
